;!function (win) {
    var UploadOSS = function () {
    };
    //上传
    UploadOSS.prototype.upload = function (type, config) {
        render(type, config)
    };
    win.upLoadOss = new UploadOSS();
}(window);

/**
 * @param type 上传云种类,分类名称需与js配置文件名相同
 * @param config type为阿里云时的上传配置 url,max_size(单位：kb,mb...),container,flash_swf_url,silverlight_xap_url,filters,prevent_duplicates(文件是否重复)
 *               PostInit提交初始化{id1:ossfile,id2:postfiles},error{id},serverUrl上传的服务器存储位置,multi_selection是否多文件上传（单文件上传设置为true）
 * */

var render = function (type, config) {
    loadJS("/cloud/" + type + ".js", function () {
        go(config)
    })
}

/**
 * 动态加载js
 * @param url js路径*/
function loadJS(url, callback) {
    var script = document.createElement('script'),
        fn = callback || function () {
        };
    script.type = 'text/javascript';
    //IE
    if (script.readyState) {
        script.onreadystatechange = function () {
            if (script.readyState == 'loaded' || script.readyState == 'complete') {
                script.onreadystatechange = null;
                fn();
            }
        };
    } else {
        //其他浏览器
        script.onload = function () {
            fn();
        };
    }
    script.src = url;
    document.getElementsByTagName('head')[0].appendChild(script);
}
